﻿/****************************************************************
*   作者：qq918
*   创建时间：2017/12/20 19:00:29
*   描述说明：
*****************************************************************/

using Model;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEditor;
using UnityEngine;

namespace MyEditor
{
    public class ToolsEditor : EditorWindow
    {
        [MenuItem("Tools/资源打包工具")]
        public static void ShowBuildEditorWindow()
        {
            GetWindow(typeof(ToolsEditor), false, "资源打包工具", true);
        }

        private BuildOptions buildOptions = BuildOptions.None;
        private Vector2 pos = Vector2.zero;
        private string _currentDefine = "";
        private void OnGUI()
        {
           
            GUILayout.BeginArea(new Rect(10, 10, 250, 60));

            GUILayout.BeginHorizontal();
            if( GUILayout.Button("标记",GUILayout.MinHeight(24)))
            {
                AssetBundleTools.SetAllLabels();
            }
            if(GUILayout.Button("清除", GUILayout.MinHeight(24)))
            {
                AssetBundleTools.RemoveAllLables();
            }
            GUILayout.EndHorizontal();
            GUILayout.EndArea();
            
            GUILayout.BeginArea(new Rect(10, 50, 250, 240));

            this.buildOptions = (BuildOptions)EditorGUILayout.EnumMaskField("BuildOptions(可多选):", this.buildOptions);

            GUILayout.BeginHorizontal();

            if ( GUILayout.Button("Widnows 打包",GUILayout.MaxWidth(90)))
            {
                AssetBundleTools.BuildWindows();
            }
            if(GUILayout.Button("打包到更新文件夹"))
            {
                AssetBundleTools.BuildWindowsToServer();
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Android 打包", GUILayout.MaxWidth(90)))
            {

            }
            if(GUILayout.Button("打包到更新文件夹"))
            {

            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            if (GUILayout.Button("IOS 打包", GUILayout.MaxWidth(90)))
            {

            }
            if(GUILayout.Button("打包到更新文件夹"))
            {

            }
            GUILayout.EndHorizontal();
            GUILayout.Space(10);
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("生成Version", GUILayout.MaxWidth(90)))
            {
                AssetBundleTools.CreateVersion();
            }
            if (GUILayout.Button("清空Unity中的打包"))
            {
                AssetBundleTools.DeleteAll();
            }
            GUILayout.EndHorizontal();
            GUILayout.Space(5);
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("开启资源服务器", GUILayout.MinHeight(24), GUILayout.MaxWidth(90)))
            {
                AssetBundleTools.OpenFileServer();
            }
            if (GUILayout.Button("清空服务器资源", GUILayout.MinHeight(24)))
            {
                Directory.Delete(PathHelper.ResServerPath);
            }
            GUILayout.EndHorizontal();
            GUILayout.EndArea();

            GUILayout.BeginArea(new Rect(10, 250, 250, 240));


            GUILayout.BeginHorizontal();
            if (GUILayout.Button("本地资源文件夹"))
            {
                AssetBundleTools.OpenPersistentDataDir();
            }
            if ( GUILayout.Button("服务器文件夹"))
            {
                AssetBundleTools.OpenServerResDir();
            }
            GUILayout.EndHorizontal();

            //if (GUILayout.Button("添加 ILR"))
            //{

            //}
            GUILayout.EndArea();
        }
    }
}